= field_set do
  = f.input :mode, as: :radio_buttons
  #transporter
    = f.referenced_association :transporter, source: :necessary_transporters, new: {transporter: 1}
    = f.input :reference_number
  #us
    = f.input :started_at
    = f.input :stopped_at
    = f.referenced_association :driver
    = f.nested_association(:tools)
  = f.referenced_association :responsible, source: :contacts
  = f.input :annotation
  = f.custom_fields

- parcel_choices = f.object.available_parcels
- if parcel_choices.any?
  = field_set :parcels, title: Delivery.human_attribute_name(:parcels) do
    %table
      %thead
        %tr
          %th
          %th= Parcel.human_attribute_name(:number)
          %th= Parcel.human_attribute_name(:nature)
          %th= Entity.model_name.human
          %th= Parcel.human_attribute_name(:items)
      %tbody
        = f.collection_check_boxes :parcel_ids, parcel_choices, :id, :number do |p|
          %tr
            %td= p.check_box
            %td= p.object.number
            %td= p.object.nature.l
            %td= Maybe(p.object.sender || p.object.recipient).name.or_else('&ndash;'.html_safe)
            %td= p.object.content_sentence

= f.attachments_field_set

